/**
 * Created by ZT on 2018/4/27 0027.
 */
/*
公共的方法
*表单提交前的验证
 *
  *
* */
function validateForm($form){
    $form.validator({
        onValid: function(validity) {
            $(validity.field).closest('.am-form-group').find('.am-alert').hide();
        },
        onInValid:function (validity) {
            var $tooltip = $('<div id="vld-tooltip">提示信息！</div>');
            $tooltip.appendTo(document.body);
            $form.on('focusin focusout', '.am-form-error input', function(e) {
                if (e.type === 'focusin') {
                    var $this = $(this);
                    var offset = $this.offset();
                    var validator = $form.data('amui.validator');
                    var msg = $this.data('foolishMsg') || validator.getValidationMessage($this.data('validity'));

                    $tooltip.text(msg).show().css({
                        left: offset.left + 10,
                        top: offset.top + $(this).outerHeight() + 10
                    });
                } else {
                    $tooltip.hide();
                }
            });
        }

    });

}